package com.yunyao.dao.service.bamu.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yunyao.common.constant.enums.DataDeletedStatus;
import com.yunyao.dao.model.BamuContractContacter;
import com.yunyao.dao.mapper.BamuContractContacterMapper;
import com.yunyao.dao.service.bamu.IBamuContractContacterService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 合同联系人 服务实现类
 * </p>
 *
 * @author xingjishuai
 * @since 2024-07-02
 */
@Service
public class BamuContractContacterServiceImpl extends ServiceImpl<BamuContractContacterMapper, BamuContractContacter> implements IBamuContractContacterService {
    @Autowired
    private BamuContractContacterMapper bamuContractContacterMapper;
    @Override
    public BamuContractContacter getByPhoneAndName(String contractId, String phone,String name) {
        LambdaQueryWrapper<BamuContractContacter> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper
                .eq(BamuContractContacter::getContractId,contractId)
                .eq(BamuContractContacter::getPhone,phone)
                .eq(BamuContractContacter::getName,name).eq(BamuContractContacter::getIsDeleted, DataDeletedStatus.NO.getType());
        List<BamuContractContacter> contacterList = bamuContractContacterMapper.selectList(queryWrapper);
        if (CollectionUtils.isNotEmpty(contacterList)){
            return contacterList.get(0);
        }
        return null;
    }
}
